{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name '2704'
test("2704 (is_truthy)", tests)
terminate_this_custom_script

function tests
    it("should be false", test1)
    it("should be true", test2)
    return
    
    function test1
    // int
        2704: is_truthy {value} 0
        assert_result_false()
        
        0@ = 0
        2704: is_truthy {value} 0@
        assert_result_false()
        
    // float
        2704: is_truthy {value} 0.0
        assert_result_false()
        
        0@ = 0.0
        2704: is_truthy {value} 0@
        assert_result_false()
        
    // short string
        2704: is_truthy {value} ''
        assert_result_false()
        
        0@s = ''
        2704: is_truthy {value} 0@s
        assert_result_false()
        
    // long string
        2704: is_truthy {value} ""
        assert_result_false()
        
        0@v = ""
        2704: is_truthy {value} 0@v
        assert_result_false()
    end
    
    function test2
    // int
        2704: is_truthy {value} 1
        assert_result_true()
        
        0@ = 1
        2704: is_truthy {value} 0@
        assert_result_true()
        
        2704: is_truthy {value} 0x00001000
        assert_result_true()
        
        2704: is_truthy {value} -1
        assert_result_true()
                
    // float
        0@ = 0.000001
        2704: is_truthy {value} 0@
        assert_result_true()
        
        2704: is_truthy {value} 1.0
        assert_result_true()
                
        0@ = 0.000001
        2704: is_truthy {value} 0@
        assert_result_true()
        
        2704: is_truthy {value} 0.000001
        assert_result_true()
        
        2704: is_truthy {value} -0.0 // it is 0x80000000
        assert_result_true()
        
    // short string
        2704: is_truthy {value} 'a'
        assert_result_true()
        
        0@s = 'a'
        2704: is_truthy {value} 0@s
        assert_result_true()
        
        2704: is_truthy {value} ' '
        assert_result_true()
        
        2704: is_truthy {value} 'null'
        assert_result_true()
        
    // long string
        2704: is_truthy {value} "a"
        assert_result_true()
        
        0@v = "a"
        2704: is_truthy {value} 0@v
        assert_result_true()
        
        2704: is_truthy {value} " "
        assert_result_true()
        
        2704: is_truthy {value} "null"
        assert_result_true()
        
        2704: is_truthy {value} "some very long testing string"
        assert_result_true()
    end    
end
